<template>
  <div>
    <navs/>
     <div class="login">
        <div class="lg-box">
          <div class="lg-head">
            <img src="../assets/img/lg-logo.png" alt="">
          </div>
          <div class="lg-cont">
            <div class="lg-nav">
             <!-- <div class="nav-item" :class="{active: login == 1}" @click="loginMethod(1)">微信登录</div>-->
              <div class="nav-item" :class="{active: login == 2}" @click="loginMethod(2)">账号登录</div>
            </div>
            <div class="lg-form">
              <!--微信登录-->
              <div class="form-item" v-if="login == 1">
                <div class="wx-img">
                  <img src="../assets/img/login_code.jpg" alt="">
                  <div class="infoBox">
                    <p class="des1">
                      请使用 微信 扫描二维码登录空心
                    </p>
                    <p class="des2">
                      没有账号？ 请
                      <router-link class="link" to="/register">注册</router-link>
                    </p>
                  </div>
                </div>
              </div>
              <!--账号登陆-->
              <div class="form-item" v-else>
                <div class="yzmdl">
                  <div class="ipt-item">
                    <input type="text" v-model="mobile" placeholder="手机" class="form-control">
                  </div>
                  <div class="ipt-item">
                    <input type="password" v-model="password" placeholder="密码"   class="form-control">
                  </div>
                  <a href="javascript:" class="btn btn-primary" @click="submit()">登录</a>
                </div>
              </div>
            </div>
          </div>

        </div>
     </div>
    <footers/>
  </div>
</template>

<script>
  import navs from '../components/nav'
  import footers from '../components/footer'
  import axios from 'axios'
  export default {
    name: "login",
    data() {
      return {
        mobile:'',
        password:'',
        login: 2    //登陆方式，1微信，2账号
      }
    },
    methods: {
      loginMethod(num) {
        this.login = num;
      },
      submit(){
        if(this.mobile==''){
          alert("请输入手机号");
        }

       if(this.password==''){
              alert("请输入密码");
              return false;
       }


          var that=this;
         axios.post(this.HOST+'/api/User/login', {
                account: this.mobile,
                password: this.password,
             })
              .then(function (response) {
                  var info=response.data.data;
                  localStorage.setItem('userinfo',JSON.stringify(info));
                  alert("登录成功");
                  that.$router.push({path:'/'});
              })
              .catch(function (response) {
                  console.log(response);
              });
      }
    },
    components: {
      navs,
      footers
    }
  }
</script>

<style scoped>
  img {
    vertical-align: middle;
  }
  .btn {
    -webkit-border-radius: 2px;
    -moz-border-radius: 2px;
    border-radius: 2px;
    font-weight: 300;
  }
  .btn {
    display: inline-block;
    padding: 6px 12px;
    margin-bottom: 0;
    font-size: 14px;
    font-weight: normal;
    line-height: 1.428571429;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    background-image: none;
    border: 1px solid transparent;
    border-radius: 4px;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -o-user-select: none;
    user-select: none;
  }
  .login {
    background: #f6f7fb;
    width: 100%;
    height: 100%;
    padding-bottom: 26px;
    min-height: 727px;
    /* margin-bottom: 155px; */
    padding-top: 35px;
  }
  .lg-box {
    width: 440px;
    height: 510px;
    margin: 0 auto;
    border-radius: 4px;
    box-shadow: 0 10px 10px #dedde3;
    background: #fff;
  }
  .lg-box .lg-head {
    height: 95px;
    background: url("../assets/img/lg-bg.png") no-repeat;
    background-size: 100%;
    text-align: center;
  }
  .lg-box .lg-head img {
    width: 80px;
    margin-top: 40px;
  }
  .lg-box .lg-cont {
    position: relative;
    padding: 10px 60px;
    height: 420px;
  }
  .lg-box .lg-nav {
    font-size: 0;
    margin-bottom: 30px;
    margin-top: 0px;
  }
  .lg-box .lg-nav .nav-item {
    display: inline-block;
    width: 100%;
    line-height: 50px;
    border-bottom: 2px solid #eee;
    font-size: 16px;
    text-align: center;
    color: #666;
    cursor: pointer;
  }
  .lg-box .lg-nav .nav-item.active {
    border-bottom: 2px solid #3CC8B4;
    color: #3CC8B4;
  }
  .lg-box .wx-img {
    height: 300px;
    text-align: center;
  }
  .lg-box .wx-img img {
    width: 170px;
  }
  .lg-box .wx-img .infoBox {
    width: 100%;
    text-align: center;
    font-size: 14px;
    color: #6c7786;
    margin-top: 8px;
  }
  .lg-box .wx-img .infoBox .des1 {
    width: 100%;
    text-align: center;
  }
  .lg-box .wx-img .infoBox .des2 {
    margin-top: 60px;
  }
  .lg-box .wx-img .infoBox .des2 .link {
    color: #3CC8B4;
  }
  .form-control {
    display: block;
    width: 100%;
    height: 34px;
    padding: 6px 12px;
    font-size: 14px;
    font-weight: 300;
    line-height: 1.428571429;
    color: #555;
    vertical-align: middle;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
    box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
    -webkit-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
    transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
  }
  .lg-box .ipt-item {
    position: relative;
    margin-bottom: 30px;
  }
  .lg-box .ipt-item input {
    position: relative;
    z-index: 2;
    border: none;
    border-radius: 0;
    outline: none;
    box-shadow: none;
    border-bottom: 1px solid #ededed;
  }
  .lg-box .ipt-item span {
    position: absolute;
    z-index: 3;
    left: 0;
    top: 0;
    color: #aaaab4;
    font-size: 14px;
    pointer-events: none;
    transition: all ease .3s;
  }
  .lg-box .ipt-item input:focus {
    border-color: #3CC8B4;
  }
  .lg-box .ipt-item input:focus ~ span {
    top: -20px;
    font-size: 14px;
    color: #3CC8B4;
    transition: all ease .3s;
  }
  .codebut {
    position: absolute;
    right: 0;
    top: 0;
    min-width: 100px;
    height: 35px;
    line-height: 33px;
    border: 1px solid #3462ff;
    color: #fff;
    text-align: center;
    font-size: 14px;
    border-radius: 3px;
    margin-top: 10px;
    background: #3462ff;
    font-family: "microsoft yahei","Open Sans";
    font-weight: 300;
  }
  .lg-box .ipt-item .butn {
    float: right;
    margin-top: -7px;
    z-index: 100;
    background: #fff;
    border: 0px;
    color: #3CC8B4;
    margin-right: -8px;
  }
  .lg-box .ipt-item .butn:HOVER {
    color: #999;
  }
  .lg-box .btn {
    display: block;
    width: 100%;
    height: 40px;
    line-height: 26px;
    letter-spacing: 3px;
    background: #4D5775;
    border-color: #4D5775;
    color: #FFF;
  }
</style>
